﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

namespace DFGK_WMS.WebAPI
{
    public class OverallException : IAsyncExceptionFilter
    {
        ///全局异常处理
        public Task OnExceptionAsync(ExceptionContext context)
        {
            if (!context.ExceptionHandled)
            {
                //还没处理的异常进来

                //记录日志

                context.Result = new ContentResult()
                {
                    Content ="发现异常错误："+context.Exception.Message
                };

                context.ExceptionHandled = true;  //标注下当前这个异常已经处理过了
            }
            return Task.CompletedTask;
        }
    }
}
